home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / DrawPixX.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  5.0 KB  |  141 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. /* Define calls if using function pointers or not */
  40. #ifdef FUNCTION_PTRS
  41.   #ifdef MULTIIMAGE
  42.     #define DRAWPIX_CALL   (*drawPixels)(width, height, format, type, *imagePtr++);
  43.   #else
  44.     #define DRAWPIX_CALL   (*drawPixels)(width, height, format, type, image);
  45.   #endif
  46.   #define PIXELSTORE_CALL  (*pixelStore)
  47.   #if (RASTERPOS_DIM == 2)
  48.     #define RASTERPOS_CALL   (*rasterPos2fv)(posPtr); posPtr += 2;
  49.   #else
  50.     #define RASTERPOS_CALL   (*rasterPos3fv)(posPtr); posPtr += 3;
  51.   #endif
  52. #else
  53.   #ifdef MULTIIMAGE
  54.     #define DRAWPIX_CALL   glDrawPixels(width, height, format, type, *imagePtr++);
  55.   #else
  56.     #define DRAWPIX_CALL   glDrawPixels(width, height, format, type, image);
  57.   #endif
  58.   #define PIXELSTORE_CALL  glPixelStorei
  59.   #if (RASTERPOS_DIM == 2)
  60.     #define RASTERPOS_CALL   glRasterPos2fv(posPtr); posPtr += 2;
  61.   #else
  62.     #define RASTERPOS_CALL   glRasterPos3fv(posPtr); posPtr += 3;
  63.   #endif
  64. #endif
  65.  
  66. void FUNCTION (TestPtr thisTest)
  67. {
  68.     DrawPixelsPtr this = (DrawPixelsPtr)thisTest;
  69.     int iterations = this->iterations;
  70.     int numDrawn = this->numDrawn;
  71.     int width = this->drawPixelsWidth;
  72.     int height = this->drawPixelsHeight;
  73.   #ifdef SUBIMAGE
  74.     GLint imageWidth = this->image_DrawPixels.imageWidth;
  75.   #endif
  76.     int format = this->image_DrawPixels.imageFormat;
  77.     int type = this->image_DrawPixels.imageType;
  78.     int i,j;
  79.   #ifdef MULTIIMAGE
  80.     int numObjects = this->numObjects;
  81.     int k;
  82.     void **imageData = this->imageData;
  83.     void **imagePtr = imageData;
  84.   #else
  85.     void *image = *(this->imageData);
  86.   #endif
  87.   #ifdef SUBIMAGE
  88.     GLint *subImageData = this->subImageData;
  89.     GLint *subPtr = subImageData;
  90.   #endif
  91.     GLfloat *traversalData = this->traversalData;
  92.     GLfloat *posPtr = traversalData;
  93.   #ifdef FUNCTION_PTRS
  94.    #ifdef WIN32
  95.     void (APIENTRY *drawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid*) = glDrawPixels;
  96.     void (APIENTRY *pixelStore)(GLenum, GLint) = glPixelStorei;
  97.     #if (RASTERPOS_DIM == 2)
  98.      void (APIENTRY *rasterPos2fv)(const GLfloat*) = glRasterPos2fv;
  99.     #else
  100.      void (APIENTRY *rasterPos3fv)(const GLfloat*) = glRasterPos3fv;
  101.     #endif
  102.    #else
  103.     void (*drawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid*) = glDrawPixels;
  104.     void (*pixelStore)(GLenum, GLint) = glPixelStorei;
  105.     #if (RASTERPOS_DIM == 2)
  106.      void (*rasterPos2fv)(const GLfloat*) = glRasterPos2fv;
  107.     #else
  108.      void (*rasterPos3fv)(const GLfloat*) = glRasterPos3fv;
  109.     #endif
  110.    #endif
  111.   #endif
  112.  
  113.   #ifdef SUBIMAGE
  114.     PIXELSTORE_CALL(GL_UNPACK_ROW_LENGTH, imageWidth);
  115.   #endif
  116.     for (i = iterations; i > 0; i--) {
  117.     for (j = numDrawn; j > 0; j--) {
  118.       #ifdef SUBIMAGE
  119.         PIXELSTORE_CALL(GL_UNPACK_SKIP_PIXELS, *subPtr++);
  120.         PIXELSTORE_CALL(GL_UNPACK_SKIP_ROWS, *subPtr++);
  121.       #endif        
  122.         RASTERPOS_CALL
  123.           #ifdef MULTIIMAGE
  124.         for (k = numObjects; k > 0; k--)
  125.           #endif
  126.         DRAWPIX_CALL
  127.           #ifdef MULTIIMAGE
  128.         imagePtr = imageData;
  129.           #endif
  130.     }
  131.     posPtr = traversalData;
  132.       #ifdef SUBIMAGE
  133.     subPtr = subImageData;
  134.       #endif
  135.     }
  136. }
  137.  
  138. #undef DRAWPIX_CALL
  139. #undef PIXELSTORE_CALL
  140. #undef RASTERPOS_CALL
  141.